package service

import (
	"context"
	"go.opentelemetry.io/otel"

	"github.com/cloudwego/hertz/pkg/app"
	user "userapi/hertz_gen/user"
	rpcmodel "userrpc/kitex_gen/user"
	"userrpc/rpc"
)

type EditPasswordService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewEditPasswordService(Context context.Context, RequestContext *app.RequestContext) *EditPasswordService {
	return &EditPasswordService{RequestContext: RequestContext, Context: Context}
}

func (h *EditPasswordService) Run(req *user.User) (resp *user.Response, err error) {
	// 链路追踪
	spanCtx, span := otel.Tracer("editPasswd").Start(h.Context, "editPasswdRpc")
	r, err := rpc.Client().EditPassword(spanCtx, &rpcmodel.User{})
	span.End()
	if err != nil {
		return
	}
	resp = new(user.Response)
	resp.Message = r.Message
	return
}
